<template>
    <br />
    <br />
    <br />
    <button @click="getData">获取数据</button>
    <ul>
        <li v-for="item in loveTalkStore.messages" :key="item.id">{{ item.title }}</li>
    </ul>

</template>
<script setup lang="ts">
import axios from 'axios';
import useLoveTalkStore from '@/store/loveTalk';
const loveTalkStore = useLoveTalkStore()
// https://api.uomg.com/
const getData = async () => {
    const { data: { content: title } } = await axios.get('/uomg/api/rand.qinghua?format=json')
    loveTalkStore.addMessage(title)
}

loveTalkStore.$subscribe((mutation, state) => {
    console.log(mutation, state)
    localStorage.setItem('messages', JSON.stringify(state.messages))
})

</script>
<style lang="scss" scoped></style>
